<?php

namespace App\Console;

use App\Console\Commands\LogInfo;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        LogInfo::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();

        //综合数据统计
        $schedule->command('complex_data_log')
            ->everyMinute() //每分钟执行一次（除此之外还有，每五、十、十五、三十...，不同方法设置的默认时间不同）
            ->withoutOverlapping() //防止重复执行
            ->onOneServer() //在单台服务器上跑
            ->runInBackground() //任务后台运行
            //->appendOutputTo('log_path')//日志输出，默认追加
            ->sendOutputTo('log_path'); //日志输出，默认覆盖先前日志
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
